﻿using System;
using BLL;
using DAL;
using Ext.Net;
using Roles;

namespace ERP.Modules
{
    public partial class Interview : System.Web.UI.UserControl
    {
        #region[Define]
        private static bool _flag;
        #endregion

        #region[Controller]
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                CheckPermisstion();
                GetInterview();
                btnEdit.Disable(true);
                btnDel.Disable(true);
                btnExport.Disable(true);
                btnReview.Disable(true);
            }
        }
        //Store
        protected void StoreInterview_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            txtSearch.Text = string.Empty;
            GetInterview();
        }
        protected void StoreInterviewApplicants_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            txtSearchInterviewApplicants.Text = string.Empty;
            GetApplicants();
        }
        protected void StoreInterview_Detail_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            if (_flag)
            {
                GetInterviewDetailTemp();
            }
            else
            {
                GetInterviewEdit(int.Parse(lbID.Text));
            }
        }
        //Button
        protected void btnAddNew_Click(object sender, DirectEventArgs e)
        {
            _flag = true;
            btnSavePopUp.Enable(true);
            btnDelPlan.Enable(true);
            btnCheck.Disable(true);
            TabsResult.Disable(true);
            TabPanelMain.SetActiveTab(TabInfo);
            ClearText();
            DeleteValueTemp();
            GetInterviewDetailTemp();
            WindowsInterview.Show();
        }
        protected void btnEdit_Click(object sender, DirectEventArgs e)
        {
            TabPanelMain.SetActiveTab(TabInfo);
            btnSavePopUp.Enable(true);
            btnDelPlan.Enable(true);
            btnCheck.Disable(true);
            TabsResult.Disable(true);
            var sm = grInterview.GetSelectionModel() as CheckboxSelectionModel;
            if (sm != null)
                foreach (var row in sm.SelectedRows)
                {
                    _flag = false;
                    ClearText();
                    GetInterviewEdit(int.Parse(row.RecordID));
                    WindowsInterview.Show();
                }
        }
        protected void btnDel_Click(object sender, DirectEventArgs e)
        {
            var sm = grInterview.GetSelectionModel() as CheckboxSelectionModel;
            if (sm != null)
                foreach (var row in sm.SelectedRows)
                {
                    try
                    {
                        var obj = new EtInterview { Interview_ID = int.Parse(row.RecordID) };
                        BllInterview.Delete(obj);
                    }
                    catch (Exception ex)
                    {
                        HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
                    }
                }
            GetInterview();
        }
        protected void btnSavePopUp_Click(object sender, DirectEventArgs e)
        {
            Insert();
        }
        protected void btnCancelPopUp_Click(object sender, DirectEventArgs e)
        {
            WindowsInterview.Close();
        }
        protected void linkApplicants_Click(object sender, DirectEventArgs e)
        {
            GetApplicants();
            WindowInterviewApplicants.Show();
        }
        protected void btnAddQuestions_Click(object sender, DirectEventArgs e)
        {
            if (_flag)
            {
                if (string.IsNullOrEmpty(txtInterview_Questions.Text))
                {
                    HTML.clsFormat.Alert_ERROR("Lỗi", "Vui lòng điền vào nội dung câu hỏi !");
                }
                else
                {
                    InsertValueDetail();
                }
            }
            else
            {
                if (string.IsNullOrEmpty(txtInterview_Questions.Text))
                {
                    HTML.clsFormat.Alert_ERROR("Lỗi", "Vui lòng điền vào nội dung câu hỏi !");
                }
                else
                {
                    InsertValueDetailEdit();
                }
            }
        }
        protected void btnDelPlan_Click(object sender, DirectEventArgs e)
        {
            var sm = grInterview_Detail.GetSelectionModel() as CheckboxSelectionModel;
            if (sm != null)
                foreach (var row in sm.SelectedRows)
                {
                    try
                    {
                        var obj = new EtInterviewDetail { Interview_Detail = int.Parse(row.RecordID) };
                        BllInterviewDetail.Delete(obj);
                    }
                    catch (Exception ex)
                    {
                        HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
                    }
                }
            if (_flag)
            {
                GetInterviewDetailTemp();
            }
            else
            {
                GetInterviewEdit(int.Parse(lbID.Text));
            }
        }
        protected void btnReview_Click(object sender, DirectEventArgs e)
        {
            TabPanelMain.SetActiveTab(TabsResult);
            btnSavePopUp.Disable(true);
            btnDelPlan.Disable(true);
            btnCheck.Enable(true);
            TabsResult.Enable(true);
            var sm = grInterview.GetSelectionModel() as CheckboxSelectionModel;
            if (sm != null)
                foreach (var row in sm.SelectedRows)
                {
                    _flag = false;
                    ClearText();
                    GetInterviewEdit(int.Parse(row.RecordID));
                    WindowsInterview.Show();
                }
        }
        protected void btnCheck_Click(object sender, DirectEventArgs e)
        {
            Review();
        }
        protected void btnAnswer_Click(object sender, DirectEventArgs e)
        {
            if (String.IsNullOrEmpty(txtAnswer.Text))
            {
                HTML.clsFormat.Alert_ERROR("Thông Báo", "Vui lòng điền vào nội dung trả lời !");
            }
            else
            {
                Answer();
            }
        }
        protected void btnAnswerCancel_Click(object sender, DirectEventArgs e)
        {
            WindowAnswer.Close();
        }
        //Double-Click
        protected void InterviewDblClick(object sender, DirectEventArgs e)
        {
            _flag = false;
            btnSavePopUp.Enable(true);
            btnDelPlan.Enable(true);
            btnCheck.Disable(true);
            TabPanelMain.SetActiveTab(TabInfo);
            TabsResult.Disable(true);
            ClearText();
            int Interview_ID = int.Parse(e.ExtraParams["Interview_ID"]);
            GetInterviewEdit(Interview_ID);
            WindowsInterview.Show();
        }
        protected void grInterview_Detail_DblClick(object sender, DirectEventArgs e)
        {
            int Interview_Detail = int.Parse(e.ExtraParams["Interview_Detail"]);
            GetInterviewAnswer(Interview_Detail);
            WindowAnswer.Show();
        }
        //Cell-Click
        protected void CellInterviewApplicants_Click(object sender, DirectEventArgs e)
        {
            var sm = grInterviewApplicants.GetSelectionModel() as CellSelectionModel;
            if (sm != null)
            {
                var id = sm.SelectedCell.RecordID;
                GetApplicantsEdit(int.Parse(id));
            }
            if (sm != null)
            {
                sm.Clear();
                sm.UpdateSelection();
            }
            WindowInterviewApplicants.Close();
        }
        //Search
        protected void Search_Event(object sender, DirectEventArgs e)
        {

        }
        protected void InterviewApplicants_Event(object sender, DirectEventArgs e)
        {
            
        }
        #endregion

        #region[Method]
        private void GetApplicants()
        {
            var _clsGetApplicants = new BllApplicants();
            var _dtGetApplicants = _clsGetApplicants.GetApplicants(string.Empty);
            if (_dtGetApplicants != null && _dtGetApplicants.Rows.Count > 0)
            {
                StoreInterviewApplicants.DataSource = _dtGetApplicants;
                StoreInterviewApplicants.DataBind();
            }
            else
            {
                grInterviewApplicants.GetStore().RemoveAll();
            }
        }
        private void GetApplicantsEdit(int id)
        {
            var _clsGetApplicants = new BllApplicants();
            var _dtGetApplicants = _clsGetApplicants.GetApplicantsEdit(id);
            if (_dtGetApplicants != null && _dtGetApplicants.Rows.Count > 0)
            {
                txtApplicants_ID.Text = _dtGetApplicants.Rows[0]["Applicants_ID"].ToString();
                txtInterview_No.Text = _dtGetApplicants.Rows[0]["Applicants_No"].ToString();
                txtInterview_Name.Text = _dtGetApplicants.Rows[0]["Applicants_Name"].ToString();
                txtInterview_Identification.Text = _dtGetApplicants.Rows[0]["Applicants_Identification"].ToString();
                txtInterview_PlaceOfIssue.Text = _dtGetApplicants.Rows[0]["Applicants_PlaceOfIssue"].ToString();
                txtInterview_BirthDay.Text = _dtGetApplicants.Rows[0]["Applicants_BirthDay"].ToString();
                if (_dtGetApplicants.Rows[0]["Applicants_Gender"].ToString() == "Nam")
                {
                    chkInterview_Gender_Male.Checked = true;
                }
                if (_dtGetApplicants.Rows[0]["Applicants_Gender"].ToString() == "Nữ")
                {
                    chkInterview_Gender_FeMale.Checked = true;
                }
                txtEthnic.Text = _dtGetApplicants.Rows[0]["Ethnic_Name"].ToString();
                txtEthnic_ID.Text = _dtGetApplicants.Rows[0]["Ethnic_ID"].ToString();
                txtReligion.Text = _dtGetApplicants.Rows[0]["Religion_Name"].ToString();
                txtReligion_ID.Text = _dtGetApplicants.Rows[0]["Religion_ID"].ToString();
                txtInterview_Address.Text = _dtGetApplicants.Rows[0]["Applicants_Address"].ToString();
                txtDistricts.Text = _dtGetApplicants.Rows[0]["Districts_Name"].ToString();
                txtDistricts_ID.Text = _dtGetApplicants.Rows[0]["Districts_Id"].ToString();
                txtProvince.Text = _dtGetApplicants.Rows[0]["Province_Name"].ToString();
                txtProvince_ID.Text = _dtGetApplicants.Rows[0]["Province_Id"].ToString();
                txtInterview_Address_Staying.Text = _dtGetApplicants.Rows[0]["Applicants_Address_Staying"].ToString();
                txtDistricts_Staying.Text = _dtGetApplicants.Rows[0]["Districts_Name_Staying"].ToString();
                txtDistricts_ID_Staying.Text = _dtGetApplicants.Rows[0]["Districts_Id_Staying"].ToString();
                txtProvince_Staying.Text = _dtGetApplicants.Rows[0]["Province_Name_Staying"].ToString();
                txtProvince_ID_Staying.Text = _dtGetApplicants.Rows[0]["Province_Id_Staying"].ToString();
                txtInterview_Email.Text = _dtGetApplicants.Rows[0]["Applicants_Email"].ToString();
                txtInterview_Phone.Text = _dtGetApplicants.Rows[0]["Applicants_Phone"].ToString();
                txtInterview_Mobie.Text = _dtGetApplicants.Rows[0]["Applicants_Mobie"].ToString();
                txtEducational_Level.Text = _dtGetApplicants.Rows[0]["Educational_Name"].ToString();
                txtEducational_Level_ID.Text = _dtGetApplicants.Rows[0]["Educational_Level_ID"].ToString();
                txtSector.Text = _dtGetApplicants.Rows[0]["Sector_Name"].ToString();
                txtSector_ID.Text = _dtGetApplicants.Rows[0]["Sector_ID"].ToString();
                txtInterview_Language_Level.Text = _dtGetApplicants.Rows[0]["Applicants_Language_Level"].ToString();
                txtInterview_Informatics.Text = _dtGetApplicants.Rows[0]["Applicants_Informatics"].ToString();
                txtInterview_YearsOfExperience.Text = _dtGetApplicants.Rows[0]["Applicants_YearsOfExperience"].ToString();
                txtInterview_Wage_Current.Text = _dtGetApplicants.Rows[0]["Applicants_Wage_Current"].ToString();
                txtInterview_Wage_Order.Text = _dtGetApplicants.Rows[0]["Applicants_Wage_Order"].ToString();
                txtInterview_Skills.Text = _dtGetApplicants.Rows[0]["Applicants_Skills"].ToString();
                txtInterview_Experience.Text = _dtGetApplicants.Rows[0]["Applicants_Experience"].ToString();
                txtInterview_Objectives.Text = _dtGetApplicants.Rows[0]["Applicants_Objectives"].ToString();
                txtInterview_Introduce.Text = _dtGetApplicants.Rows[0]["Applicants_Introduce"].ToString();
                txtInterview_Notes.Text = _dtGetApplicants.Rows[0]["Applicants_Notes"].ToString();
            }
        }
        private void GetInterview()
        {
            var _clsGetInterview = new BllInterview();
            var _dtGetInterview = _clsGetInterview.GetInterview(string.Empty);
            if (_dtGetInterview != null && _dtGetInterview.Rows.Count > 0)
            {
                StoreInterview.DataSource = _dtGetInterview;
                StoreInterview.DataBind();
            }
            else
            {
                grInterview.GetStore().RemoveAll();
            }
        }
        private void GetInterviewEdit(int id)
        {
            var _clsGetInterviewEdit = new BllInterview();
            var _clsGetInterviewDetail = new BllInterviewDetail();
            var _dtGetInterviewDetail = _clsGetInterviewDetail.GetInterviewDetail(id);
            var _dtGetInterviewEdit = _clsGetInterviewEdit.GetInterview(string.Empty);
            if (_dtGetInterviewEdit != null && _dtGetInterviewEdit.Rows.Count > 0)
            {
                lbID.Text = _dtGetInterviewEdit.Rows[0]["Interview_ID"].ToString();
                txtApplicants_ID.Text = _dtGetInterviewEdit.Rows[0]["Applicants_ID"].ToString();
                txtInterview_No.Text = _dtGetInterviewEdit.Rows[0]["Applicants_No"].ToString();
                txtInterview_Name.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Name"].ToString();
                txtInterview_Identification.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Identification"].ToString();
                txtInterview_PlaceOfIssue.Text = _dtGetInterviewEdit.Rows[0]["Applicants_PlaceOfIssue"].ToString();
                txtInterview_BirthDay.Text = _dtGetInterviewEdit.Rows[0]["Applicants_BirthDay"].ToString();
                if (_dtGetInterviewEdit.Rows[0]["Applicants_Gender"].ToString() == "Nam")
                {
                    chkInterview_Gender_Male.Checked = true;
                }
                if (_dtGetInterviewEdit.Rows[0]["Applicants_Gender"].ToString() == "Nữ")
                {
                    chkInterview_Gender_FeMale.Checked = true;
                }
                txtEthnic.Text = _dtGetInterviewEdit.Rows[0]["Ethnic_Name"].ToString();
                txtEthnic_ID.Text = _dtGetInterviewEdit.Rows[0]["Ethnic_ID"].ToString();
                txtReligion.Text = _dtGetInterviewEdit.Rows[0]["Religion_Name"].ToString();
                txtReligion_ID.Text = _dtGetInterviewEdit.Rows[0]["Religion_ID"].ToString();
                txtInterview_Address.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Address"].ToString();
                txtDistricts.Text = _dtGetInterviewEdit.Rows[0]["Districts_Name"].ToString();
                txtDistricts_ID.Text = _dtGetInterviewEdit.Rows[0]["Districts_Id"].ToString();
                txtProvince.Text = _dtGetInterviewEdit.Rows[0]["Province_Name"].ToString();
                txtProvince_ID.Text = _dtGetInterviewEdit.Rows[0]["Province_Id"].ToString();
                txtInterview_Address_Staying.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Address_Staying"].ToString();
                txtDistricts_Staying.Text = _dtGetInterviewEdit.Rows[0]["Districts_Name_Staying"].ToString();
                txtDistricts_ID_Staying.Text = _dtGetInterviewEdit.Rows[0]["Districts_Id_Staying"].ToString();
                txtProvince_Staying.Text = _dtGetInterviewEdit.Rows[0]["Province_Name_Staying"].ToString();
                txtProvince_ID_Staying.Text = _dtGetInterviewEdit.Rows[0]["Province_Id_Staying"].ToString();
                txtInterview_Email.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Email"].ToString();
                txtInterview_Phone.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Phone"].ToString();
                txtInterview_Mobie.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Mobie"].ToString();
                txtEducational_Level.Text = _dtGetInterviewEdit.Rows[0]["Educational_Name"].ToString();
                txtEducational_Level_ID.Text = _dtGetInterviewEdit.Rows[0]["Educational_Level_ID"].ToString();
                txtSector.Text = _dtGetInterviewEdit.Rows[0]["Sector_Name"].ToString();
                txtSector_ID.Text = _dtGetInterviewEdit.Rows[0]["Sector_ID"].ToString();
                txtInterview_Language_Level.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Language_Level"].ToString();
                txtInterview_Informatics.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Informatics"].ToString();
                txtInterview_YearsOfExperience.Text = _dtGetInterviewEdit.Rows[0]["Applicants_YearsOfExperience"].ToString();
                txtInterview_Wage_Current.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Wage_Current"].ToString();
                txtInterview_Wage_Order.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Wage_Order"].ToString();
                txtInterview_Skills.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Skills"].ToString();
                txtInterview_Experience.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Experience"].ToString();
                txtInterview_Objectives.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Objectives"].ToString();
                txtInterview_Introduce.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Introduce"].ToString();
                txtInterview_Notes.Text = _dtGetInterviewEdit.Rows[0]["Applicants_Notes"].ToString();
                if (_dtGetInterviewEdit.Rows[0]["Applicants_Notes"].ToString() == "Đạt yêu cầu")
                {
                    rdOk.Checked = true;
                }
                if (_dtGetInterviewEdit.Rows[0]["Applicants_Notes"].ToString() == "Không đạt yêu cầu")
                {
                    rdNot.Checked = true;
                }
                if (_dtGetInterviewEdit.Rows[0]["Applicants_Notes"].ToString() == "Phỏng vấn lần sau")
                {
                    rdLater.Checked = true;
                }
                if (_dtGetInterviewDetail != null && _dtGetInterviewDetail.Rows.Count > 0)
                {
                    StoreInterview_Detail.DataSource = _dtGetInterviewDetail;
                    StoreInterview_Detail.DataBind();
                }
                else
                {
                    grInterview_Detail.GetStore().RemoveAll();
                }
            }
        }
        private void GetInterviewAnswer(int id)
        {
            var _clsGetInterviewEdit = new BllInterviewDetail();
            var _dtGetInterviewEdit = _clsGetInterviewEdit.GetInterviewDetailEdit(id);
            if (_dtGetInterviewEdit != null && _dtGetInterviewEdit.Rows.Count > 0)
            {
                txtID_Detail.Text = _dtGetInterviewEdit.Rows[0]["Interview_Detail"].ToString();
                txtQuestion.Text = _dtGetInterviewEdit.Rows[0]["Interview_Questions"].ToString();
                txtAnswer.Text = _dtGetInterviewEdit.Rows[0]["Interview_Answer"].ToString();
            }
        }
        private void GetInterviewDetailTemp()
        {
            var _clsGetInterviewDetailTemp = new BllInterviewDetail();
            var _dtGetInterviewDetailTemp =
                _clsGetInterviewDetailTemp.GetInterviewDetailTemp(int.Parse(Session["Users_Id"].ToString()));
            if (_dtGetInterviewDetailTemp != null && _dtGetInterviewDetailTemp.Rows.Count > 0)
            {
                StoreInterview_Detail.DataSource = _dtGetInterviewDetailTemp;
                StoreInterview_Detail.DataBind();
            }
            else
            {
                grInterview_Detail.GetStore().RemoveAll();
            }
        }
        private void Insert()
        {
            if (_flag)
            {
                InsertValue();
            }
            else
            {
                if (CheckPermisstionDobclick())
                {
                    HTML.clsFormat.Alert_ERROR("Thông Báo", "Bạn không được cấp quyền để sửa đổi !");
                }
                else
                {
                    UpdateValue();
                }
            }
        }
        private void InsertValue()
        {
            try
            {
                var obj = new EtInterview
                {
                    Applicants_ID = int.Parse(txtApplicants_ID.Text),
                    Interview_Result = DBNull.Value.ToString(),
                    Interview_Note = txtInterview_Note.Text,
                    Users_Id = int.Parse(Session["Users_Id"].ToString()),
                    DateBegin = DateTime.Parse(DateTime.Now.ToString())
                };
                BllInterview.Insert(obj);
                HTML.clsFormat.Alert_INFO("Thông Báo", "Thêm mới thành công !");
                GetInterview();
                ClearText();
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
            }
        }
        private void UpdateValue()
        {
            try
            {
                var obj = new EtInterview
                {
                    Interview_ID = int.Parse(lbID.Text),
                    Applicants_ID = int.Parse(txtApplicants_ID.Text),
                    Interview_Result = DBNull.Value.ToString(),
                    Interview_Note = txtInterview_Note.Text,
                    Users_Id = int.Parse(Session["Users_Id"].ToString()),
                    DateBegin = DateTime.Parse(DateTime.Now.ToString())
                };
                BllInterview.Update(obj);
                HTML.clsFormat.Alert_INFO("Thông Báo", "Cập nhật thành công !");
                GetInterview();
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
            }
        }
        private void InsertValueDetail()
        {
            try
            {
                var obj = new EtInterviewDetail
                {
                    Interview_ID = null,
                    Interview_Questions = txtInterview_Questions.Text,
                    Interview_Answer = DBNull.Value.ToString(),
                    Interview_Poit = float.Parse(txtPoint.Text),
                    Users_Id = int.Parse(Session["Users_Id"].ToString()),
                    Flag = 1
                };
                BllInterviewDetail.Insert(obj);
                HTML.clsFormat.Alert_INFO("Thông Báo", "Thêm mới thành công !");
                GetInterviewDetailTemp();
                txtInterview_Questions.Text = string.Empty;
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Lỗi", ex.Message);
            }
        }
        private void InsertValueDetailEdit()
        {
            try
            {
                var obj = new EtInterviewDetail
                {
                    Interview_ID = int.Parse(lbID.Text),
                    Interview_Questions = txtInterview_Questions.Text,
                    Interview_Answer = DBNull.Value.ToString(),
                    Interview_Poit = float.Parse(txtPoint.Text),
                    Users_Id = int.Parse(Session["Users_Id"].ToString()),
                    Flag = 0
                };
                BllInterviewDetail.Insert(obj);
                HTML.clsFormat.Alert_INFO("Thông Báo", "Thêm mới thành công !");
                GetInterviewEdit(int.Parse(lbID.Text));
                txtInterview_Questions.Text = string.Empty;
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Lỗi", ex.Message);
            }
        }
        private void DeleteValueTemp()
        {
            try
            {
                var obj = new EtInterviewDetail {Users_Id = int.Parse(Session["Users_Id"].ToString())};
                BllInterviewDetail.DeleteTemp(obj);
                GetInterviewDetailTemp();
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Lỗi", ex.Message);
            }
        }
        private void Review()
        {
            try
            {
                var obj = new EtInterview
                {
                    Interview_ID = int.Parse(lbID.Text),
                    Interview_Note = txtInterview_Note.Text,
                    Interview_Result = GetAlignmentValue()
                };
                BllInterview.Review(obj);
                HTML.clsFormat.Alert_INFO("Thông Báo", "Đánh giá thành công !");
                GetInterview();
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
            }
        }
        private void Answer()
        {
            try
            {
                var obj = new EtInterviewDetail
                {
                    Interview_Detail = int.Parse(txtID_Detail.Text),
                    Interview_Answer = txtAnswer.Text,
                };
                BllInterviewDetail.Answer(obj);
                HTML.clsFormat.Alert_INFO("Thông Báo", "Trả lời thành công !");
                GetInterviewEdit(int.Parse(lbID.Text));
                WindowAnswer.Close();
            }
            catch (Exception ex)
            {
                HTML.clsFormat.Alert_ERROR("Thông Báo", ex.Message);
            }
        }
        private string GetAlignmentValue()
        {
            foreach (var item in rdResult.CheckedItems)
            {
                if (item.ID == "rdOk")
                {
                    return "Đạt yêu cầu";
                }
                if (item.ID == "rdNot")
                {
                    return "Không đạt yêu cầu";
                }
                if (item.ID == "rdLater")
                {
                    return "Phỏng vấn lần sau";
                }
            }
            return string.Empty;
        }
        #endregion

        #region[ClearText]
        private void ClearText()
        {
            FormPanelInterview.Reset();
            lbID.Text = string.Empty;
            grInterview_Detail.GetStore().RemoveAll();
        }
        #endregion

        #region[Permisstion]
        private void CheckPermisstion()
        {
            if (Session["login"] != null && Session["USer_Detail_Id"].ToString() != string.Empty)
            {
                bool Is_BtnAdd;
                bool Is_BtnEdit;
                bool Is_BtnView;
                bool Is_BtnDel;
                bool Is_BtnPrint;
                bool Is_BtnCancel;
                bool Is_BtnReview;

                SecurityServices.HasPermisstion_Btn(StringContent.Interview, out Is_BtnAdd, out Is_BtnEdit, out Is_BtnDel, out Is_BtnView, out Is_BtnCancel, out Is_BtnPrint, out Is_BtnReview);
                if (Is_BtnAdd == false)
                {
                    btnAddNew.Visible = false;
                }
                if (Is_BtnEdit == false)
                {
                    btnEdit.Visible = false;
                }
                if (Is_BtnView == false)
                {
                    PanelInterview.Visible = false;
                }
                if (Is_BtnDel == false)
                {
                    btnDel.Visible = false;
                }
                if (Is_BtnPrint == false)
                {
                    btnExport.Visible = false;
                }
            }
        }
        private bool CheckPermisstionDobclick()
        {
            bool check = false;
            if (Session["login"] != null && Session["USer_Detail_Id"].ToString() != string.Empty)
            {
                bool Is_BtnAdd;
                bool Is_BtnEdit;
                bool Is_BtnView;
                bool Is_BtnDel;
                bool Is_BtnPrint;
                bool Is_BtnCancel;
                bool Is_BtnReview;

                SecurityServices.HasPermisstion_Btn(StringContent.Interview, out Is_BtnAdd, out Is_BtnEdit, out Is_BtnDel, out Is_BtnView, out Is_BtnCancel, out Is_BtnPrint, out Is_BtnReview);
                if (Is_BtnEdit == false)
                {
                    check = true;
                }
            }
            return check;
        }
        #endregion
    }
}